package com.zh.note.huawei.onehundred.最长公共后缀;

/**
 * https://dream.blog.csdn.net/article/details/131158605
 */
public class Main {
    public static void main(String[] args) {
        // Scanner sc = new Scanner(System.in);
        // String input = sc.nextLine();
        // String[] strs = input.replace("[", "").replace("]", "")
        //         .replace("\"", "")
        //         .split(",");
        // String[] strs = {"abc", "bbc", "bc"};
        String[] strs = {"aa", "bb", "cc"};
        String first = strs[0];
        for (int i = 1; i < strs.length; i++) {
            String str = strs[i];
            int j = 1;
            while (first.length() - j >= 0 && str.length() - j >= 0
                    && first.charAt(first.length() - j) == str.charAt(str.length() - j)) {
                j++;
            }
            if (j == 1) {
                first = "@Zero";
                break;
            }
            first = first.substring(first.length() - j + 1);
        }
        System.out.println(first);
    }
}
